/*
 * Copyright (c) 2013.
 * 游戏服务器核心代码编写人陈磊拥有使用权
 * 联系方式：E-mail:13638363871@163.com ;qq:502959937
 * 个人博客主页：http://my.oschina.net/chenleijava
 */

package com.dc.gameserver.serverCore.service.character;

import com.dc.gameserver.hardCode.CardType;
import com.dc.gameserver.hardCode.PkStatus;
import com.dc.gameserver.serverCore.service.cardModule.Card;
import com.dc.gameserver.serverCore.service.cardModule.CardBox;
import com.dc.gameserver.serverCore.service.cardModule.CardBoxManager;
import io.netty.buffer.ByteBuf;
import javolution.util.FastTable;

import java.io.Serializable;

/**
 * 游戏对象  战斗模型  RPG
 */
public abstract class GameCharacter implements Serializable {

    /**对象编号      role ID : player和 数据库vo关联***/
    private int ID;//
    /**对象名***/
    private String name;//对象名
    /**先手***/
    private boolean firstHand=false;
    /**玩家纸牌库***/
    private FastTable<Card> cardlib=null;
    /**玩家出牌临时列表 检查牌是否是统一类型，同时最大出牌不得超过限制，保存玩家回合中纸牌，进入
     *一回合将会被情况，注意此列表中的数据牌会直接参与到核心玩法中的逻辑运算中***/
    private FastTable<Card> outCardsList=null;
    /**玩家是否处于(进入)pk状态*****/
    private PkStatus pkStatus=null;
    /**玩家当前所在回合局中所出在预出牌区域的牌类型*/
    private CardType cardType=null;
    /**玩家被成功神识之后，眩晕次数*/
    private int DizzinessTimes=0;
    /**玩家所持用的cardBox ID*/
    private int cardBoxID;
    /**玩家放弃出牌标识***/
    private boolean giveOut=false;
    /**玩家出牌动作是否发生，用于回合出牌前计时机制*****/
    private boolean actionOutCard=false;

    /**战斗属性 当前法力盾 法力值 当前回合数值，当回合开始，自动增加到role中最大属性值，用于回合计算***/
    private int CurrentShield;
    private int CurrentMagic;
    private int CurrentBlood;
    private int RecoveryMagic;//法力恢复值
    private int Attack;//攻击值
    private int Defence; //防御值
    private int BaseMaxMomentum;  //气势值上限
    private int BaseMinMomentum;       //气势值下限
    private int MaxSual;  //神识上限
    private int soul;//角色当前神识值,怪物只有神识上限
    private int maxShield;
    private int maxMagic;
    private int maxBlood;
    private int fiveTypeSkillValue;//攻方五行技能数值
    /**获取系统出牌点数基础数据源**/
    private int minCount;
    private int maxCount;

    /**使用防牌技能消耗，法力盾恢复值***/
    private int FangreduceMagic;
    private int Fangrecoverysheild;

    /**使用技能牌，技能的消耗***/
    private int reduceMagic;


    /****
     * monster， player 根据当前player所处的境界来决定其出牌数量
     * stateID(大境界编号) maxHoldCard（最大持牌数）maxGetCard（最大摸牌数） maxOutCard（最大出牌数量）
     * */
    private int maxHoldCard;//（最大持牌数）
    private int maxGetCard;//（最大摸牌数）
    private int maxOutCard;//（最大出牌数量）

    private int battleSkillID;//玩家战斗中使用的技能


    private int selfFiveType;//自身的五行属性
    private int skillfiveType;//角色技能五行属性

    public int getSelfFiveType() {
        return selfFiveType;
    }



    /**
     * 当玩家不在持有cardBox，将会回收所有的card，保持cardBox的完整性
     * 回收card资源对象
     */
    public void RecoverCard(CardBox cardBox){
        if (outCardsList.size()!=0){
            for (Card card:this.outCardsList){
                cardBox.returnPool(card);
            }
            this.outCardsList.clear();
        }
        if (this.cardlib.size()!=0){
            for (Card card:this.cardlib){
                cardBox.returnPool(card);
            }
            this.cardlib.clear();
        }
    }


    /**
     * 玩家处于pk状态进行中！！！
     * 回合中回收Card
     * 容器中的card对象，只设定了类型，没有设定点数，而定数有player境界决定
     * 所以在回收的时候，要重置点数 ，保持cardBox对象的完整性
     */
    public void recoverRoundCard(){
        CardBox cardBox= CardBoxManager.getCardBoxByID(this.cardBoxID);
        for (Card card:this.outCardsList){
            cardBox.returnPool(card);
        }
        this.outCardsList.clear();
    }

    /**
     * 发送数据
     * @param bufferData
     */
    public  void DirectSend(ByteBuf bufferData){}


    /**
     *玩家获取系统产生的物品接口
     */
    public void insterItemToPlayer(int[] items){};

    /**
     * 持久化玩家的数据
     * 释放系统资源
     */
    public  void saveAndDestory(){};
    /**
     * 移除指定的card对象
     */
    public  Card removeIncardlib(int cardType,int count){return null;};

    /**
     *  PK结束，清理PK资源,   cardBox 对象持有的card资源
     */
    public abstract  void clearPkResourceWithRoundOver(CardBox cardBox);

    /**
     * PK没有结束
     当前回合结束，清除当前回合中的资源，重置，准备下一次回合资源
     */
    public abstract void clearRoundResource();

    /**
     *添加系统分发的纸牌对象列表
     * @param disCardList   系统分发的纸牌对象列表
     */
    public abstract void add(Card[] disCardList);

    /**
     清除资源 离开pk状态  回收card资源
     */
    public abstract void clearAllResourceOutOfPK(CardBox cardBox);

    /**
     * 添加出牌对象到预出牌区列表对象 outCardsList
     * @param card
     */
    public abstract void addOutCard(Card card);

    public int getReduceMagic() {
        return reduceMagic;
    }

    public void setReduceMagic(int reduceMagic) {
        this.reduceMagic = reduceMagic;
    }

    public int getFangreduceMagic() {
        return FangreduceMagic;
    }

    public void setFangreduceMagic(int fangreduceMagic) {
        FangreduceMagic = fangreduceMagic;
    }

    public int getFangrecoverysheild() {
        return Fangrecoverysheild;
    }

    public void setFangrecoverysheild(int fangrecoverysheild) {
        Fangrecoverysheild = fangrecoverysheild;
    }


    public int getMinCount() {
        return minCount;
    }

    public void setMinCount(int minCount) {
        this.minCount = minCount;
    }

    public int getMaxCount() {
        return maxCount;
    }

    public void setMaxCount(int maxCount) {
        this.maxCount = maxCount;
    }
    public int getFiveTypeSkillValue() {
        return fiveTypeSkillValue;
    }

    public void setFiveTypeSkillValue(int fiveTypeSkillValue) {
        this.fiveTypeSkillValue = fiveTypeSkillValue;
    }

    /**
     * 获取当前玩家纸牌张数</br>
     * 会影响到发牌张数，且不会超过最大拥有牌数量值  </br>
     * @return   纸牌张数     </br>
     */
    public int getCurrentCardSize(){
        return cardlib.size();
    }


    public int getSoul() {
        return soul;
    }

    public void setSoul(int soul) {
        this.soul = soul;
    }

    public int getRecoveryMagic() {
        return RecoveryMagic;
    }

    public void setRecoveryMagic(int recoveryMagic) {
        RecoveryMagic = recoveryMagic;
    }

    public int getAttack() {
        return Attack;
    }

    public void setAttack(int attack) {
        Attack = attack;
    }

    public int getDefence() {
        return Defence;
    }

    public void setDefence(int defence) {
        Defence = defence;
    }

    public int getBaseMaxMomentum() {
        return BaseMaxMomentum;
    }

    public void setBaseMaxMomentum(int baseMaxMomentum) {
        BaseMaxMomentum = baseMaxMomentum;
    }

    public int getBaseMinMomentum() {
        return BaseMinMomentum;
    }

    public void setBaseMinMomentum(int baseMinMomentum) {
        BaseMinMomentum = baseMinMomentum;
    }

    public int getMaxSual() {
        return MaxSual;
    }

    public void setMaxSual(int maxSual) {
        MaxSual = maxSual;
    }


    public int getCurrentBlood() {
        return CurrentBlood;
    }

    public void setCurrentBlood(int currentBlood) {
        CurrentBlood = currentBlood;
    }


    public boolean isFirstHand() {
        return firstHand;
    }

    public void setFirstHand(boolean firstHand) {
        this.firstHand = firstHand;
    }

    public FastTable<Card> getCardlib() {
        return cardlib;
    }

    public void setCardlib(FastTable<Card> cardlib) {
        this.cardlib = cardlib;
    }

    public FastTable<Card> getOutCardsList() {
        return outCardsList;
    }

    public void setOutCardsList(FastTable<Card> outCardsList) {
        this.outCardsList = outCardsList;
    }

    public PkStatus getPkStatus() {
        return pkStatus;
    }

    public void setPkStatus(PkStatus pkStatus) {
        this.pkStatus = pkStatus;
    }

    public CardType getCardType() {
        return cardType;
    }

    public void setCardType(CardType cardType) {
        this.cardType = cardType;
    }

    public int getDizzinessTimes() {
        return DizzinessTimes;
    }

    public void setDizzinessTimes(int dizzinessTimes) {
        DizzinessTimes = dizzinessTimes;
    }

    public int getCardBoxID() {
        return cardBoxID;
    }

    public void setCardBoxID(int cardBoxID) {
        this.cardBoxID = cardBoxID;
    }

    public boolean isGiveOut() {
        return giveOut;
    }

    public void setGiveOut(boolean giveOut) {
        this.giveOut = giveOut;
    }
    public int getBattleSkillID() {
        return battleSkillID;
    }

    public void setBattleSkillID(int battleSkillID) {
        this.battleSkillID = battleSkillID;
    }
    public boolean isActionOutCard() {
        return actionOutCard;
    }

    public void setActionOutCard(boolean actionOutCard) {
        this.actionOutCard = actionOutCard;
    }

    public int getCurrentShield() {
        return CurrentShield;
    }

    public void setCurrentShield(int currentShield) {
        CurrentShield = currentShield;
    }

    public int getCurrentMagic() {
        return CurrentMagic;
    }

    public void setCurrentMagic(int currentMagic) {
        CurrentMagic = currentMagic;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public int getMaxHoldCard() {
        return maxHoldCard;
    }

    public void setMaxHoldCard(int maxHoldCard) {
        this.maxHoldCard = maxHoldCard;
    }

    public int getMaxGetCard() {
        return maxGetCard;
    }

    public void setMaxGetCard(int maxGetCard) {
        this.maxGetCard = maxGetCard;
    }

    public int getMaxOutCard() {
        return maxOutCard;
    }

    public void setMaxOutCard(int maxOutCard) {
        this.maxOutCard = maxOutCard;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public int getMaxBlood() {
        return maxBlood;
    }

    public void setMaxBlood(int maxBlood) {
        this.maxBlood = maxBlood;
    }

    public int getMaxShield() {
        return maxShield;
    }

    public void setMaxShield(int maxShield) {
        this.maxShield = maxShield;
    }

    public int getMaxMagic() {
        return maxMagic;
    }

    public void setMaxMagic(int maxMagic) {
        this.maxMagic = maxMagic;
    }

    public void setSelfFiveType(int selfFiveType) {
        this.selfFiveType = selfFiveType;
    }

    public int getSkillfiveType() {
        return skillfiveType;
    }

    public void setSkillfiveType(int skillfiveType) {
        this.skillfiveType = skillfiveType;
    }
}
